package com.gibs.peixunapi.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import com.gibs.peixunapi.model.SubscribeCourse;

@Repository
public interface SubscribeCourseDao extends JpaRepository<SubscribeCourse, Integer>, JpaSpecificationExecutor<SubscribeCourse> {

	@Query("from SubscribeCourse where companyId = ?1")
	List<SubscribeCourse> find(String name);

	@Query("from SubscribeCourse where companyId like ?1")
	List<SubscribeCourse> findLike(String name);

	@Query(value = "select * from SubscribeCourse limit ?, ?", nativeQuery = true)
	List<SubscribeCourse> findPage(Integer offset, Integer size);

	@Query(value = "select * from SubscribeCourse where companyId = ? limit ?, ?", nativeQuery = true)
	List<SubscribeCourse> findPage(String name, Integer offset, Integer size);

	@Query(value = "select * from SubscribeCourse where companyId like ? limit ?, ?", nativeQuery = true)
	List<SubscribeCourse> findPageLike(String name, Integer offset, Integer size);

	@Query(value = "select count(*) from SubscribeCourse where companyId = ?", nativeQuery = true)
	Long count(String name);

	@Query(value = "select count(*) from SubscribeCourse where companyId like ?", nativeQuery = true)
	Long countLike(String name);
	
	@Query("from SubscribeCourse order by id asc")
	List<SubscribeCourse> findAllAsc();
}

